package com.example.a10928.weifriend.adapter

import android.content.Intent
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.a10928.weifriend.App.activity
import com.example.a10928.weifriend.R
import com.example.a10928.weifriend.http.api.VariableName
import com.example.a10928.weifriend.ui.task_center.MemberTaskListActivity
import com.example.a10928.weifriend.ui.task_center.TaskDetailsActivity
import com.example.a10928.weifriend.view.TaskListItemLayout
import kotlinx.android.synthetic.main.item_member_task.view.*

class MemberTaskAdapter(layout: Int, data: List<TaskItemData>) :
        BaseQuickAdapter<MemberTaskAdapter.TaskItemData, BaseViewHolder>(layout, data) {

    var type:String=""
    constructor(layout: Int, data: List<TaskItemData>, t:String):this(layout,data){
        type=t

    }


    override fun convert(helper: BaseViewHolder?, item: TaskItemData?) {
        var listItemLayout: TaskListItemLayout = helper!!.getView(R.id.item_member)
        listItemLayout.setIv(item!!.img)
        listItemLayout.setName(item.name)
        listItemLayout.setPrice(item.price)
        listItemLayout.setState(item.state)
        listItemLayout.setTask_tv_size(item.isShowSize)
        listItemLayout.setTask_check_tv(item.isShowCheck)
        listItemLayout.setOnClickListener {
            val intent = Intent(activity, TaskDetailsActivity::class.java)
            intent.putExtra(TaskDetailsActivity.SOURCE_TASKDETAILS_TYPE, item!!.type)
            intent.putExtra(TaskDetailsActivity.DATA_TAKE_THE_TASK, item!!.adId)
            intent.putExtra(VariableName.DATA,type)
            mContext.startActivity(intent)
        }
    }


    public class TaskItemData(img: Int, name: String, state: String, price: String, type: Int, adId: Int,isShowSize: Boolean,isShowCheck :Boolean) {
        public var img = img;
        public var name = name;
        public var state = state;
        public var price = price;
        public var adId = adId;
        public var type = type
        public var isShowSize = isShowSize
        public var isShowCheck = isShowCheck
    }
}